package com.gxa.controller;

import com.gxa.pojo.*;
import com.gxa.utils.Constants;
import com.gxa.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: zxy
 * Date: 2020/11/26 16:15
 * Description:
 * Version: V1.0
 */
@RestController
@RequestMapping("/invoice")
@Api(value = "发货单",tags = "发货单")
public class invoiceController {

    @Autowired
    private ResponseData responseData;

    @GetMapping(value = "/queryInvoice")
    @ApiOperation(value = "查询发货单",notes = "查询发货单",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryInvoice(){
        Invoice invoice = new Invoice();
        invoice.setInvoiceSernum("发货单流水号");
        invoice.setInvoiceOrdercode("asdasdas");
        invoice.setInvoiceOrdertime(new Date());
        invoice.setInvoiceDt(new Date());
        invoice.setInvoiceStatus(1);
        Order order = new Order();
        order.setOrderCode("asdasfasd");
        Im im = new Im();
        im.setImOperator("操作者");
        invoice.setIm(im);
        invoice.setOrder(order);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(invoice);
        return responseData;
    }

    @GetMapping(value = "/queryInvoiceByTerm")
    @ApiOperation(value = "根据条件查询发货单",notes = "根据条件查询发货单",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryInvoiceByTerm(String invoiceSernum, String invoiceOrdercode, String memName){
        Invoice invoice = new Invoice();
        invoice.setInvoiceSernum("发货单流水号"+invoiceSernum);
        invoice.setInvoiceOrdercode("asdasdas"+invoiceOrdercode);
        invoice.setInvoiceOrdertime(new Date());
        invoice.setInvoiceDt(new Date());
        invoice.setInvoiceStatus(1);
        Order order = new Order();
        order.setOrderCode("asdasfasd");
        Im im = new Im();
        im.setImOperator("操作者");
        MemLocations memLocations = new MemLocations();
        memLocations.setMemName("收货人"+memName);
        invoice.setIm(im);
        invoice.setOrder(order);
        invoice.setMemLocations(memLocations);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(invoice);
        return responseData;
    }

    @GetMapping(value = "/queryInvoiceDetails")
    @ApiOperation(value = "查询发货单详情",notes = "查询发货单详情",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryInvoiceDetails() {
        Invoice invoice = new Invoice();
        invoice.setInvoiceSernum("发货单流水号");
        invoice.setInvoiceOrdercode("asdasdas");
        invoice.setInvoiceOrdertime(new Date());
        invoice.setInvoiceBu("购买用户");
        invoice.setInvoiceDt(new Date());
        invoice.setInvoiceDm("配送方式");
        invoice.setInvoiceDc(50.00);
        invoice.setInvoiceCm("客户留言");
        invoice.setInvoiceIn("发货单号");
        invoice.setInvoiceSq(1);
        MemLocations memLocations = new MemLocations();
        memLocations.setMemName("姓名");
        memLocations.setMemNum("手机");
        memLocations.setMemLocation("地址");
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        Comspec comspec = new Comspec();
        comspec.setNumber("货号");
        goods.setComspec(comspec);
        invoice.setGoods(goods);
        invoice.setMemLocations(memLocations);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(invoice);
        return responseData;
    }

    @GetMapping(value = "/deliveryOperationInformation")
    @ApiOperation(value = "发货操作信息",notes = "发货操作信息",httpMethod = "GET", response = ResponseData.class)
    public ResponseData deliveryOperationInformation(){
        Invoice invoice = new Invoice();
        Im im = new Im();
        im.setImOperator("操作者");
        im.setImRemarks("操作备注");
        im.setImOt(new Date());
        im.setImOrderstatus(1);
        im.setImPaymentstatus(1);
        im.setImShipmentsstatus(1);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(invoice);
        return responseData;
    }
}
